import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Index',
      component: () => import('@/views/Index'),
      redirect:'/top',
      children:[
        {
          path: '/films',
          name: 'Films',
          component: () => import('@/views/Films'),
        },
        {
          path: '/happy',
          name: 'Happy',
          component: () => import('@/views/Happy'),
        },
        {
          path: '/know',
          name: 'Knowledge',
          component: () => import('@/views/Knowledge'),
        },
        {
          path: '/baby',
          name: 'Baby',
          component: () => import('@/views/Baby'),
        },
        {
          path: '/top',
          name: 'Top',
          component: () => import('@/views/Top'),
        },
        {
          path: '/star',
          name: 'Star',
          component: () => import('@/views/Star'),
        },
        {
          path: '/food',
          name: 'Food',
          component: () => import('@/views/Food'),
        }
      ]
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('@/views/admin/Login'),
    },
    {
      path: '/admin',
      name: 'Admin',
      meta: {
        requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
      },
      component: () => import('@/views/admin/Admin'),
      children:[
        {
          path: '/user',
          name: 'User',
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          component: () => import('@/views/admin/User'),
        },{
          path: '/role',
          name: 'Role',
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          component: () => import('@/views/admin/Role'),
        },{
          path: '/classity',
          name: 'Classity',
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          component: () => import('@/views/admin/Classity'),
        },{
          path: '/news',
          name: 'News',
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          component: () => import('@/views/admin/News'),
        }
      ]
    }
  ]
})
